
	******************************************************************
	**
	**
	**		NAME:		GUY GROSSMAN and YOTAM MARGALIT
	**		DATE: 		December 15, 2021
	**		PROJECT: 	Israel Hayom
	**		DETAILS: 	This file has a code for placebo test reported in Table SI-16
	**		Version: 	Stata MP 16
	**
	******************************************************************
	
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**

	set scheme plotplainblind, permanently
	clear
	version 16
	set more off

	* Set the global

	capture cd "~/dropbox/Israeli Newspapers Study/JOP_REPLICATION/Dataverse submission"

	* Bring in dataset

	use "Data/yeshuvlong_final.dta"

	* additional cleaning
		
	replace israelhayom_percent_e=0 if israelhayom_percent_e==. & year<2007
	replace israelhayom_percent=0 if israelhayom_percent==. & year<2007
	replace israelhayom_percent_cumulative=0 if israelhayom_percent_cumulativ==. & year<2007

	drop if area_num >25

	keep if BIG_rightbloc!=.
	tabulate year, gen(YEAR)

	* generating a running number for election years 	
	egen yr = group(year)
	move yr year

	gen lpop= log(potential)
	gen ltd = log(travel_dist)

	* generate turnout var
	gen turnout = voters/potential
	replace turnout = 1 if turnout>1
	replace turnout = turnout*100
	tab year, summ(turnout)

	* population share by age group
	gen pop_share1829 = pop_M_18_29 / pop_total 
	gen pop_share3049 = pop_M_30_49 /pop_total
	gen pop_share5065 = pop_M_50_65 /pop_total
	gen pop_share66 = pop_M_66 / pop_total
	gen pop_adult = pop_M_18_29 + pop_M_30_49 + pop_M_50_65 + pop_M_66
	 
	 foreach var in pop_share1829 pop_share3049 pop_share5065 pop_share66{
		replace `var'=0 if `var'<0
	 }

	tabstat ltd lpop age_median_08 matriccert_pcnt_08 europe_pcnt_08 asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66, by(yr)

	corr ltd lpop age_median_08 potential matriccert_pcnt_08 europe_pcnt_08  asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66 if yr==4

	* generate otherpapers var for attentativeness measure
	egen otherpapers=rowtotal(maariv_percent haaretz_percent globes_percent marker_percent calcalist_percent israelpost_percent makorrishon_percent) if year==2006
		bysort area_num: egen otherpapers2006=max(otherpapers)
		drop otherpapers
		
	* rename parties	

	ren BIG_rightbloc BRB
	ren israelhayom_percent_electionyear IHE

	* rename instruments
	ren secular_max IVsm
	ren secular_max07H1 IVsm07H1
	ren sec_max06h2_07H1 IVsm06h2_07H1

	tabstat IVsm IVsm07H1 IVsm06h2_07H1,  by(year)
	corr IVsm IVsm07H1 IVsm06h2_07H1
	drop IVsm

	bysort area_num: egen IVsm=mean(IVsm07H1)
	bysort area_num: egen IVsmp=mean(IVsm06h2_07H1)
	tabstat IVsm IVsmp, by(year)
	drop IVsm07H1 IVsm06h2_07H1

	* generate variable of base level of support for right bloc and Likud
	foreach var in BRB Plikud {
		bysort uniqueid: egen `var'0 = mean(`var') if yr<5
		bysort uniqueid: egen `var'Pre = mean(`var'0)
		drop `var'0
		}

	* use LERI score to calculate mean ideology support at baseline 
	table year uniqueid if uniqueid<6, c(mean leri_score )	
	foreach var in leri_AVscore leri_score{
		bysort uniqueid: egen `var'0 = mean(`var') if yr<5
		bysort uniqueid: egen `var'Pre = mean(`var'0)
		drop `var'0
		}
			
	*******************************
	* Regression for Placebo test *
	*******************************
	
	estimates drop _all
		
	xtset uniqueid yr
	sort uniqueid yr

	gen fIHE = f.IHE
	gen fIHEb = f2.IHE
	replace fIHE =0 if yr==1
	
	foreach var in BRB Plikud {
	
		bootstrap, reps(250) seed(6375) cl(area) idcl(new_area) group(uniqueid) force: reghdfe `var' fIHE [aw=potential] if yr<5, absorb(uniqueid yr) cl(area)	
				estadd local lag "1-year"
				capture est sto `var'5
					
		bootstrap, reps(250) seed(6375) cl(area) idcl(new_area) group(uniqueid) force: reghdfe `var' fIHEb [aw=potential] if yr<5, absorb(uniqueid yr) cl(area)	
				estadd local lag "2-years"
				capture est sto `var'6	
						
		}
	
	* Outsheeting results to create Table SI-16
	
	# delimit ;
	
		esttab 	BRB5 BRB6 Plikud5 Plikud6  
			using "Tables/Table_SI-16.tex", replace
			keep(fIHE fIHEb _cons)
			cells(b(fmt(%5.3f) star) se(fmt(%5.3f) par))
			starlevels(* .10 ** .05 *** .01) 
			mgroups("\textbf{Right Bloc}" "\textbf{Likud}", pattern(1 0 1 0)
			span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span})) nomtitles
			varlabels(fIHE "IH exposure (1-lag)" fIHEb "IH exposure (2-lag)" _cons "Constant")
			stats(lag r2 N, labels("lag structure" "R2" "N")
			fmt(0 2 0)) collabels(none) label booktabs nonotes;
		
		#delimit cr			
